namespace Baula.TextGen.ActiveTemplating
{
    public interface IFieldInfo
    {
        string Name { get; }
    }

    public class FieldInfo : IFieldInfo
    {
        private readonly string _name;

        public FieldInfo(string name)
        {
            _name = name;
        }

        public string Name
        {
            get { return _name; }
        }

        public bool Equals(FieldInfo other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return Equals(other._name, _name);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != typeof (FieldInfo))
            {
                return false;
            }
            return Equals((FieldInfo) obj);
        }

        public override int GetHashCode()
        {
            return (_name != null ? _name.GetHashCode() : 0);
        }
    }
}